import numpy as np
from skimage.data import camera
def susan_mask():
    mask=np.ones((7,7))
    mask[0,0]=0
    mask[0,1]=0
    mask[0,5]=0
    mask[0,6]=0
    mask[1,0]=0
    mask[1,6]=0
    mask[5,0]=0
    mask[5,6]=0
    mask[6,0]=0
    mask[6,1]=0
    mask[6,5]=0
    mask[6,6]=0
    return mask
def susan_corner_detection(img):
    img = img.astype(np.float64)
    g=37/2
    circularMask=susan_mask()
    output=np.zeros(img.shape)

    for i in range(3,img.shape[0]-3):
        for j in range(3,img.shape[1]-3):
            ir=np.array(img[i-3:i+4, j-3:j+4])
            ir =  ir[circularMask==1]
            ir0 = img[i,j]
            a=np.sum(np.exp(-((ir-ir0)/10)**6))
            if a<=g:
                a=g-a
            else:
                a=0
            output[i,j]=a
    return output

image=camera()
out=susan_corner_detection(image)
from matplotlib import pyplot as plt
plt.imshow(out,cmap='gray')
plt.show()
